/**
 * Project: metacrumbs
 * File: MetaLocation.java
 * Type: MetaLocation
 * Author: unmarco
 * Created: Sep 5, 2011 10:32:27 AM
 */
package org.sensolab.metacrumbs.data.model;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.GeoPt;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.users.User;

/**
 * @author unmarco
 *
 */
@PersistenceCapable
public class MetaLocation {
	
	/**
	 * 
	 */
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	
	/**
	 * The owner (initial creator) of this MetaLocation
	 */
	@Persistent
	private User owner;
	
	/**
	 * 
	 */
	@Persistent
	private Date creationDate;
	
	/**
	 * 
	 */
	@Persistent
	private Date lastUpdated;
	
	/**
	 * 
	 */
	@Persistent
	private GeoPt geoPoint;
	
	/**
	 * 
	 */
	@Persistent
	private String title;
	
	/**
	 * 
	 */
	@Persistent
	private String description;
	
	/**
	 * Default constructor
	 */
	public MetaLocation() {
		// empty
	}
	
	/**
	 * @param owner
	 * @param geoPoint
	 * @param title
	 * @param description
	 */
	public MetaLocation(User owner, GeoPt geoPoint, String title, String description) {
		this.owner = owner;
		this.geoPoint = geoPoint;
		this.title = title;
		this.description = description;
		Date now = new Date();
		this.creationDate = now;
		this.lastUpdated = now;
	}
	
	/**
	 * @return
	 */
	public Key getKey() {
		return key;
	}
	
	/**
	 * @return
	 */
	public User getOwner() {
		return owner;
	}
	
	/**
	 * @param owner
	 */
	public void setOwner(User owner) {
		this.owner = owner;
	}
	
	/**
	 * @return
	 */
	public Date getCreationDate() {
		return creationDate;
	}
	
	/**
	 * @param creationDate
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	
	/**
	 * @return
	 */
	public Date getLastUpdated() {
		return lastUpdated;
	}
	
	/**
	 * @param lastUpdated
	 */
	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	
	/**
	 * @return
	 */
	public GeoPt getGeoPoint() {
		return geoPoint;
	}
	
	/**
	 * @param geoPoint
	 */
	public void setGeoPoint(GeoPt geoPoint) {
		this.geoPoint = geoPoint;
	}

	/**
	 * @return
	 */
	public String getTitle() {
		return title;
	}
	
	/**
	 * @param title
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	
	/**
	 * @return
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public String toString() {
		return 
			"[" + this.getClass().getSimpleName() + "]" +
			"[" + this.getGeoPoint().getLatitude() + "," + this.getGeoPoint().getLongitude() + "]" +
			"[" + this.getTitle() + "]";
	}
	
}
